package com.cuijq.ms.observer.v1;

import java.util.ArrayList;
import java.util.List;

/**
 * @author by CuiJQ
 * @Classname ConcreteSubject
 * @Description ConcreteSubject Description
 * @Date 2021/5/28 14:57
 */
public class ConcreteSubject implements Subject {

  private List<Observer> observers = new ArrayList();

  @Override
  public void registerObserver(Observer observer) {
    observers.add(observer);
  }

  @Override
  public void removeObserver(Observer observer) {
    observers.remove(observer);
  }

  @Override
  public void notifyObservers(Message message) {
    for (Observer observer : observers) {
      observer.update(message);
    }
  }
}
